﻿@using CoreData
@using Helper
@model List<ShoppingCart>
@{
    var toTalProduct = 0;
    var toTalPrice = 0;
    if (Model != null)
    {
        foreach (var item in Model)
        {
            toTalProduct = toTalProduct + item.Amount;
        }
        foreach (var item in Model)
        {
            toTalPrice = toTalPrice + item.TotalItemPrice;
        }
    }
    var totalShort = toTalProduct.ToString();
    if (toTalProduct > 10)
    {
        totalShort = "10" + "+";
    }
    <a target="_blank" class="cart-link" href="@Url.Action("Index", "ShoppingCart")">Giỏ
        hàng
        @if (toTalProduct > 0)
        {
            <span class="lu-icon lu-icon-cart"><b>@totalShort</b></span>
        }
    </a>
    <div class="top-dropdown">
        <div class="arrow-up">
        </div>
        <p class="cart-title">
            Sản phẩm vừa thêm (@toTalProduct)</p>
        @if (Model != null && Model.Count() > 0)
        {
            <ul>
                @foreach (var item in Model)
                {
                    <li><a target="_blank" href="@Url.RouteUrl("product_details", new { Id = item.Product.ID, Link = item.Product.Link })" title="@item.Product.Name" class="thumnail-cart">
                        <img src="/Media/Product/@item.Product.Image" alt="@item.Product.Image">
                    </a>
                        <div class="product-details">
                            <div class="product-name">
                                <a target="_blank" href="@Url.RouteUrl("product_details", new { Id = item.Product.ID, Link = item.Product.Link })" title="@item.Product.Name">@item.Product.Name</a></div>
                            <span>@item.Amount x @Helper.StringHelper.FormatVND(int.Parse(item.Product.Price.ToString()))</span>
                        </div>
                        <div class="clearfix">
                        </div>
                    </li>
                }
            </ul>
                
        }
        <div class="cart-total">
            <label class="lbl">
                Tổng cộng:</label><span>@Helper.StringHelper.FormatVND(int.Parse(toTalPrice.ToString()))</span>
        </div>
        <div class="cart-controls">
            <a href="@Url.Action("Index", "ShoppingCart")" class="btn" target="_blank">Xem giỏ hàng</a>
        </div>
    </div>
}
